﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>加入爱贝儿医</title>
<script src="business/js/jquery.js"></script>
<link rel="stylesheet" href="business/style/common.css">
<script src="business/resource/js/jquery-1.11.1.min.js"></script>
<script src="business/resource/js/bootstrap.min.js"></script>
<script src="business/resource/js/hermes.js"></script>
<script type="" src="app/js/common.js"></script>
    <style>
        .error1{display: none;width:50%;margin:0 auto;position:absolute;top:80px;margin-left:25%;background: #fff;height:80px;}
        .error1 .error_delete{float:right;font:20px 黑体;color:#999;padding-bottom: 8px;margin-right:8px;}
        .error1 span{width:80%;margin:0 auto;height:80px;font:13px 黑体;color:#DA304A;display: block;}
        .add{color:#ccc}
    </style>
</head>

<body>

<div class="logo"><img src="business/style/login_logo.png" /></div>
<div class="reg_form">
    <div class="line"></div>
    <div class="form_box">

        <div class="tel_icon"></div><div class="txt"><input name="tel" type="number" id="keyword" value="请输入手机号" placeholder="" onFocus="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" /></div>
    </div>
    <div class="line"></div>
    <div class="form_box">
        <div class="yzm_icon"></div><div class="txt"><input name="yanzm" type="number" id="keyword" value="请输入验证码" onFocus="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" /><div class="sent"><input name="sentyzm" type="button" value="发送验证码"><input name="" type="hidden" value="" /></div></div>
    </div>
    <div class="line"></div>
    <div class="big_btn" style="margin-top:20px; "><input name="" type="submit" class="red_btn" value="加入我们" /></div>
    <div class="tips"><a href="####">点击以上按钮，即表明您已同意《爱贝儿医用户使用协议》</a></div>
</div>
<div class="error1">
    <div class="error_delete">&times;</div>
    <div class="clear"></div>
    <span>手机号有误，请确定后重新输入！</span>
</div>
<?php require 'app/templates/common/foot.html'; ?>
</body>
</html>

<script>
    $(function(){
        //手机验证
        $("input[name='sentyzm']").click(function(){
            var value=$("input[name='tel']").val();
            reg=/^1[3|4|5|7|8][0-9]\d{8}$/;
            if(!reg.test(value)){
                $(".error1").show(500);
            }else{
                num="";
                for(var i=0;i<6;i++){
                    num+=Math.floor(Math.random()*10);
                }
                data = common.post('user', 'user_register_send_checkCode', {'tel':value,'num':num});
                if (data.result == -1) {
                    common.showMsgBox(data.message);
                } else {
                   // $("input[type='hidden']").val(num);
                    //$("input[name='yanzm']").val(num);
                    $("input[name='sentyzm']").val("请在60s内填写");
                    $("input[name='sentyzm']").attr("disabled","disabled");
                     setTimeout(show(60),1000);
                }
            }
        })

        function show(变量) {
            $("input[name='sentyzm']").val("填写验证码("+变量+"s)");
            var now=变量-1;
            if (parseInt(变量) > 0) {
                setTimeout(function () {
                    show(now);
                }, 1000);
            } else {
                
                $("input[name='sentyzm']").val("重新发送");
                $("input[name='sentyzm']").attr("disabled",false);
            }
        }
        $(".error_delete").click(function(){
            $(".error1").hide();
        });

        $("input[type='submit']").click(function(){
            var tel = $("input[name='tel']").val();
            //var telyzm=$("input[type='hidden']").val();
            var yzm = $("input[name='yanzm']").val();
            if (tel=='请输入手机号') {
                common.showMsgBox('请输入手机号');
                return false;
            }
            var reg=/^1[3|4|5|7|8][0-9]\d{8}$/;
            if(!reg.test(tel)) {
                common.showMsgBox('手机格式错误');
                return false;
            }
            if (yzm == '请输入验证码') {
                common.showMsgBox('请输入验证码');
                return false;
            }

            var reg1  = /^\d+$/;
            if (!reg1.test(yzm)) {
                common.showMsgBox('验证码格式不正确');
                return false;
            }
            data = common.post('user', 'user_register_post', {'tel':tel,'pwd':yzm});
            if (data.result == -1) {
                common.showMsgBox(data.message);
            } else {
                if (data.datas == 2) {
                    closeWind();
                } else {
                    window.location.href ="<?=$认证url?>";
                }
            }

        });
    });

    function closeWind(){
        if (typeof(WeixinJSBridge)=='undefined') {
            window.close();
        } else {
            WeixinJSBridge.invoke('closeWindow',{},function(res){
                return true;
            });
        }
    }
</script>
